package com.fifth.commodity.controller;

import com.fifth.commodity.service.BrandService;
import com.fifth.commodity.vo.BrandStateVo;
import com.fifth.commodity.vo.BrandVo;
import com.fifth.common.pojo.dto.CommonResult;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("commodity/brand")
public class BrandController {
    @Autowired
    private BrandService brandService;

    /**
     * 根据条件分页查询所有品牌
     * @param pageCurrent
     * @param pageSize
     * @param brandVo
     * @return
     */
    @ApiOperation("根据条件分页查询所有品牌")
    @ApiImplicitParams({
            @ApiImplicitParam(dataType = "int",name = "pageCurrent",value = "页码数"),
            @ApiImplicitParam(dataType = "int",name = "pageSize",value = "每页显示的个数"),
            @ApiImplicitParam(dataType = "BrandVo",name = "brandVo",value = "查询条件的实体类"),
    })
    @PostMapping("findBrandsWithCondition/{pageCurrent}/{pageSize}")
    private CommonResult findBrandsWithCondition(@PathVariable Integer pageCurrent, @PathVariable Integer pageSize, @RequestBody BrandVo brandVo){
        return brandService.findBrandsWithCondiction(pageCurrent,pageSize,brandVo);
    }

    /**
     * 查询所有店铺
     * @return
     */
    @ApiOperation(value = "查询所有店铺")
    @PostMapping("findAllBrands")
    public CommonResult findAllBrands(){
        return brandService.findAllBrands();
    }

    /**
     * 根据id删除品牌(逻辑删除)
     * @param id
     * @return
     */
    @ApiOperation(value = "根据id逻辑删除")
    @PostMapping("deleteBrand")
    public CommonResult deleteBrand(Integer id){
        return brandService.deleteBrand(id);
    }

    /**
     * 修改审核状态
     * @param brandStateVo
     * @return
     */
    @ApiOperation("修改审核状态")
    @ApiModelProperty(dataType = "StateVo",name = "stateVo",value = "接收审核状态的实体类")
    @PostMapping("updateState")
    public CommonResult updateState(@RequestBody BrandStateVo brandStateVo){
        return brandService.updateState(brandStateVo);
    }

    /**
     * 页面加载查询所有品牌
     * @return
     */
    @PostMapping("selectAllBrand")
    public CommonResult selectAllBrand(){
        return brandService.selectAllBrand();
    }
}
